package rgbos.forum.persistance;

import java.util.Vector;

import rgbos.forum.domain.Post;
import rgbos.forum.domain.Topic;
import rgbos.forum.domain.User;

public class XMLFacade implements PersImpl {

	private XMLPost xmlPost_;
	private XMLTopic xmlTopic_;
	private XMLUser xmlUser_;
	private XMLUtil xmlUtil_;

	public XMLFacade(){
		xmlPost_ = new XMLPost();
		xmlTopic_= new XMLTopic();
		xmlUser_ = new XMLUser();
		xmlUtil_ = new XMLUtil();
	}

	public void init(){
		xmlUtil_.createNewFiles();


	}
	public void createNewTables(){
		xmlUtil_.createXMLfile();
	}
	public boolean changePermission(String username, int value) {
		return xmlUser_.changePermission(username, value);
	}

	public boolean checkAdmin(String username) {
		return xmlUser_.checkAdmin(username);
	}

	public boolean checkExistUser(String username) {
		return xmlUser_.checkExistUser(username);
	}

	public boolean checkModerator(String username) {
		return xmlUser_.checkModerator(username);
	}

	public boolean deletePost(int postId) {
		return xmlPost_.deletePost(postId);
	}

	public boolean deleteTopic(int topicId) {
		return xmlTopic_.deleteTopic(topicId);
	}

	public boolean deleteUser(String username) {
		return xmlUser_.deleteUser(username);
	}

	public Post getPostById(int postId) {
		return xmlPost_.getPostById(postId);
	}

	public Vector<Post> getPosts() {
		return xmlPost_.getPosts();
	}

	public Topic getTopicById(int topicId) {
		return xmlTopic_.getTopicById(topicId);
	}

	public Vector<Topic> getTopics() {
		return xmlTopic_.getTopics();
	}

	public Vector<User> getUsers() {
		return xmlUser_.getUsers();
	}

	public boolean logIn(String userName, String pass) {
		return xmlUser_.logIn(userName, pass);
	}

	public boolean modifyPost(Post post) {
		return xmlPost_.modifyPost(post);
	}

	public boolean modifyPostBody(int postId, String body) {
		return xmlPost_.modifyPostBody(postId, body);
	}

	public boolean modifyTopic(Topic topic) {
		return xmlTopic_.modifyTopic(topic);
	}

	public boolean modifyUserDetails(User user) {
		return xmlUser_.modifyUserDetails(user);
	}

	public boolean registerNewUser(User newUser) {
		return xmlUser_.registerNewUser(newUser);
	}

	public int saveNewPost(Post post, int topicId) {
		return xmlPost_.saveNewPost(post, topicId);
	}

	public int saveNewTopic(Topic topic) {
		return xmlTopic_.saveNewTopic(topic);
	}

	public boolean setAdmin(String username) {
		return xmlUser_.setAdmin(username);
	}

	public boolean setModerator(String username) {
		return xmlUser_.setModerator(username);
	}

	public void addViewCount(int topicId) {
		xmlTopic_.addViewCount(topicId);
	}

	@Override
	public Vector<User> getOnlineUsers() {
		// XML is no longer relevant
		return null;
	}

	@Override
	public int getOnlineBit(String userName) {
		return 0;
		// TODO Auto-generated method stub

	}

	@Override
	public boolean setOnlineBit(String userName, int onlineBit) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public User getUserByName(String username) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void addCulumn(String culumnName, String culumnType) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Vector<Post> getPostsByUser(String username) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getEmailByName(String userName) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean modifyPostBody(int postId, String title, String body) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void closeConnection() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public int[] getHourStats() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean incHour(int hour) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void createUsersHours() {
		// TODO Auto-generated method stub
		
	}

	public void connect() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Topic getTopicByPost(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Vector<String> getUsersName() {
		// TODO Auto-generated method stub
		return null;
	}

}
